﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;


namespace ProjectRoughWork
{
    class Allignment : AIState
    {
        public Allignment(SquadActor[] initSquad)
            : base()
        {
            squad = initSquad;
        }

        public override void VOnUpdate()
        {
            //Calcualte the average velocity of the squad

            Vector3 averageVelocity = Vector3.Zero;

            for (int index = 0; index < 3; index++)
            {
                averageVelocity = squad[index].getVelocity();
            }

            averageVelocity.X /= 3;
            averageVelocity.Z /= 3;

            //Adjust the velocity of the actor's to push them closer to moving in the same direction

            for (int index = 0; index < 3; index++)
            {
                squad[index].setVelocity(squad[index].getVelocity() + averageVelocity);
            }

            base.VOnUpdate();
        }

        //Data Members

        SquadActor[] squad;
    }
}
